using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using bba.framework.infraweb.baseinfra.stat;
using bba.framework.infraweb.entities;
using bba.framework.infraweb.infrastructure.utility;
using bba.framework.infraweb.baseinfra;

namespace ibba.src.noriskweb.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            // Código obrigatório para compatibilidade retroativa com versões antigas da InfraWeb
            //    Descomente este bloco se deseja utilizar esta funcionalidade
            //VirtualPathProvider.PageVirtualPathProvider vpp = new VirtualPathProvider.PageVirtualPathProvider();
            //System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(vpp);
        }

        /// <summary>
        /// Evento responsável por efetuar o start da session na aplicação
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Session_Start(object sender, EventArgs e)
        {

            HttpUserNameProvider prov = new HttpUserNameProvider();
            prov.ContextProvider = new HttpContextProvider();
            new SessionStartModule().SaveStat(Session.SessionID, Request.Url.AbsoluteUri,
               prov.getCurrentUser().Name, DateTime.UtcNow.AddMinutes(Session.Timeout));
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

    }
}